﻿using UnityEngine;
using System.Collections;

/// <summary>
/// 实现开始按钮的上下浮动
/// </summary>
public class Floating : MonoBehaviour {

    /// <summary>
    /// 弧度，利用cos的范围为【-1，1】的特性实现在指定半径内来回运动的特效
    /// </summary>
    private float radian = 0f;

    /// <summary>
    /// 每次变化的弧度
    /// </summary>
    public float perRadian = 0.02f;

    /// <summary>
    /// 运动的最大半径
    /// </summary>
    public float radius = 0.2f;

    /// <summary>
    /// 初始位置
    /// </summary>
    private Vector3 initPositon;

	// Use this for initialization
	void Start () {
        initPositon = transform.position;
	}
	
	// Update is called once per frame
	void Update () {
        radian += perRadian;
        float dy = radius * Mathf.Cos(radian);
        transform.position = initPositon + new Vector3(0, dy, 0);
	}
}
